﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;
using l1cs.server.model;
using l1cs.server.serverpackets;

namespace l1cs.server.clientpackets
{
    public class C_Who : ClientBasePacket
    {
        private const String _C_WHO = "[C] C_Who";
        private static Logger _log = Logger.getLogger( typeof( C_Who ).FullName );

        public C_Who( byte[] decrypt, ClientThread client )
            : base( decrypt )
        {
            String s = readS();
            L1PcInstance find = L1World.getInstance().getPlayer( s );
            L1PcInstance pc = client.getActiveChar();

            if ( find != null )
            {
                S_WhoCharinfo s_whocharinfo = new S_WhoCharinfo( find );
                pc.sendPackets( s_whocharinfo );
            }
            else
            {
                if ( Config.ALT_WHO_COMMAND )
                {
                    String amount = L1World.getInstance().getAllPlayerCount().ToString();
                    S_WhoAmount s_whoamount = new S_WhoAmount( amount );
                    pc.sendPackets( s_whoamount );
                }
                // 対象が居ない場合はメッセージ表示する？わかる方修正お願いします。
            }
        }

        override
        public String getType()
        {
            return _C_WHO;
        }
    }
}